﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


namespace ExoticCarRental
{
    public partial class reservation_confirmation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["UserSettings"] == null)
            {
                Response.Redirect("login.aspx");
            }

            string email = Request.Cookies["UserSettings"]["email"];



            BusinessLayer bl = new BusinessLayer();
            string reservation_id = Request.QueryString["id"];
            if (reservation_id != null)
            {
                int reservationid;
                if (Int32.TryParse(reservation_id, out reservationid))
                {
                    //delete reservation
                     DataRow row = bl.GetReservationByReservationID(reservationid);

                     string days = row["days"].ToString();
                     string daily_rate = row["daily_rate"].ToString();
                     string daily_insurance_rate = row["daily_insurance_rate"].ToString();
                     Single sdays = Single.Parse(days);
                     Single sdaily_rate = Single.Parse(daily_rate);
                     Single sdaily_insurance_rate = Single.Parse(daily_insurance_rate);
                     Single totcost = (sdays * sdaily_rate) + (sdays * sdaily_insurance_rate); 
                     
 

                     lblReservationID.Text = row["reservation_id"].ToString();
                     lblEmailAddress.Text = row["email_addr"].ToString();
                     lblFirstName.Text = row["first_name"].ToString();
                     lblLastName.Text = row["last_name"].ToString();
                     lblPickUpDate.Text = row["pickup_date"].ToString();
                     lblDropOffDate.Text = row["dropoff_date"].ToString();
                     lblLocation.Text = row["location"].ToString();
                     lblCategory.Text = row["category_name"].ToString();
                     lblCreditCardNumber.Text = row["ccard_no"].ToString();
                     lblCardType.Text = row["ccard_type"].ToString();
                     lblCardExpMonth.Text = row["ccard_expmonth"].ToString();
                     lblCardExpYear.Text = row["ccard_expyear"].ToString();
                     lblDays.Text = row["days"].ToString();
                     lblDailyRate.Text =  row["daily_rate"].ToString();
                     lblDailyInsurance.Text = row["daily_insurance_rate"].ToString();
                     lblTotalCost.Text = totcost.ToString("C");






                }
            }
            else
            {
                Response.Redirect("browse.aspx");
            }

        }
    }
}
